@im-nobsidian/core 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -285,18 +285,21 @@ interface PushOptions {
285
285
  readonly force?: boolean;
286
286
  readonly dryRun?: boolean;
287
287
  readonly onProgress?: ProgressCallback;
288
+ readonly signal?: AbortSignal;
288
289
  }
289
290
  interface PullOptions {
290
291
  readonly paths?: string[];
291
292
  readonly force?: boolean;
292
293
  readonly dryRun?: boolean;
293
294
  readonly onProgress?: ProgressCallback;
295
+ readonly signal?: AbortSignal;
294
296
  }
295
297
  interface SyncOptions {
296
298
  readonly paths?: string[];
297
299
  readonly force?: boolean;
298
300
  readonly dryRun?: boolean;
299
301
  readonly onProgress?: ProgressCallback;
302
+ readonly signal?: AbortSignal;
300
303
  }
301
304
  interface PushResult {
302
305
  readonly created: number;
@@ -463,7 +466,35 @@ declare class ConfigManager {
463
466
  isInitialized(): Promise<boolean>;
464
467
  }
465
468
 
466
- declare class StateDB {
469
+ interface IStateDB {
470
+ close(): void;
471
+ getByPath(path: string): SyncRecord | null;
472
+ getByNotionId(pageId: string): SyncRecord | null;
473
+ getByStatus(status: SyncStatus): SyncRecord[];
474
+ getAll(): SyncRecord[];
475
+ upsert(record: UpsertSyncRecord): SyncRecord;
476
+ updateStatus(id: string, status: SyncStatus): void;
477
+ updateHash(id: string, hash: string, snapshot?: Buffer | Uint8Array | null): void;
478
+ setNotionLastEdited(id: string, lastEdited: string): void;
479
+ updateStatCache(id: string, mtime: string, fileSize: number): void;
480
+ setNotionParentId(id: string, parentId: string): void;
481
+ delete(id: string): void;
482
+ resolveWikilink(text: string): WikilinkEntry | null;
483
+ resolvePageId(pageId: string): WikilinkEntry | null;
484
+ upsertWikilink(entry: WikilinkEntry): void;
485
+ getMeta(key: string): string | null;
486
+ setMeta(key: string, value: string): void;
487
+ isFileRegistered(localPath: string): boolean;
488
+ getFileRegistry(localPath: string): FileRegistryEntry | null;
489
+ getFilesByPageId(notionPageId: string): FileRegistryEntry[];
490
+ registerFile(entry: RegisterFileInput): void;
491
+ deleteFileRegistry(localPath: string): void;
492
+ storePreserveMarkers(path: string, markers: PreserveMarker[]): void;
493
+ getPreserveMarkers(path: string): PreserveMarker[];
494
+ transaction<T>(fn: () => T): T;
495
+ }
496
+
497
+ declare class StateDB implements IStateDB {
467
498
  private readonly db;
468
499
  private constructor();
469
500
  static open(dbPath: string): StateDB;
@@ -534,12 +565,14 @@ interface NotionClientOptions {
534
565
  readonly token: string;
535
566
  readonly concurrency?: number;
536
567
  readonly timeoutMs?: number;
568
+ readonly fetch?: typeof globalThis.fetch;
537
569
  }
538
570
  declare class NotionClient {
539
571
  private readonly client;
540
572
  private readonly sema;
541
573
  private readonly token;
542
574
  private readonly propertyMapper;
575
+ private readonly customFetch?;
543
576
  constructor(options: NotionClientOptions);
544
577
  getInternalClient(): Client;
545
578
  getPage(pageId: string): Promise<PageObjectResponse>;
@@ -572,6 +605,19 @@ declare class NotionClient {
572
605
  id: string;
573
606
  type: string;
574
607
  }>>;
608
+ getDatabaseSchemaFull(databaseId: string): Promise<Record<string, {
609
+ id: string;
610
+ type: string;
611
+ options?: Array<{
612
+ name: string;
613
+ color?: string;
614
+ }>;
615
+ groups?: Array<{
616
+ name: string;
617
+ color?: string;
618
+ optionIds?: string[];
619
+ }>;
620
+ }>>;
575
621
  queryDatabase(databaseId: string, options?: {
576
622
  startCursor?: string;
577
623
  pageSize?: number;
@@ -761,7 +807,7 @@ interface FileInfo {
761
807
  }
762
808
  declare class ChangeDetector {
763
809
  private readonly stateDb;
764
- constructor(stateDb: StateDB);
810
+ constructor(stateDb: IStateDB);
765
811
  detectLocalChangesFast(stats: FileStatInfo[], readFile: (path: string) => Promise<string>): Promise<LocalChange[]>;
766
812
  detectLocalChanges(currentFiles: FileInfo[]): LocalChange[];
767
813
  private detectMoves;
@@ -807,7 +853,7 @@ declare class SyncOrchestrator {
807
853
  private dbSchemaLoaded;
808
854
  private _pullImageCount;
809
855
  private _pullFileCount;
810
- constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS);
856
+ constructor(config: Config, stateDb: IStateDB, notionClient: NotionClient, vaultFs: VaultFS, customFetch?: typeof globalThis.fetch);
811
857
  push(options?: PushOptions): Promise<PushResult>;
812
858
  pull(options?: PullOptions): Promise<PullResult>;
813
859
  sync(options?: SyncOptions): Promise<SyncResult>;
@@ -892,7 +938,9 @@ declare class ImageHandler {
892
938
  private readonly vaultFs;
893
939
  private readonly attachmentFolder;
894
940
  private readonly notionClient?;
895
- constructor(vaultFs: VaultFS, attachmentFolder?: string, notionClient?: NotionClient | undefined);
941
+ private readonly customFetch?;
942
+ constructor(vaultFs: VaultFS, attachmentFolder?: string, notionClient?: NotionClient | undefined, customFetch?: typeof globalThis.fetch);
943
+ private get fetchFn();
896
944
  downloadImage(url: string, pageTitle: string): Promise<ImageDownloadResult>;
897
945
  downloadAllImages(markdown: string, pageTitle: string): Promise<{
898
946
  content: string;
@@ -931,7 +979,7 @@ declare class FileHandler {
931
979
  private readonly notionClient;
932
980
  private readonly stateDb;
933
981
  private readonly sema;
934
- constructor(vaultFs: VaultFS, notionClient: NotionClient, stateDb: StateDB);
982
+ constructor(vaultFs: VaultFS, notionClient: NotionClient, stateDb: IStateDB);
935
983
  pushFilesForFolder(folderPageId: string, folderPath: string): Promise<FileUploadResult[]>;
936
984
  pushAllFiles(): Promise<FileUploadResult[]>;
937
985
  downloadFileBlock(url: string, filename: string, targetFolder: string): Promise<FileDownloadResult>;
@@ -968,11 +1016,13 @@ declare class DatabaseSyncer {
968
1016
  private readonly pipeline;
969
1017
  private readonly imageHandler;
970
1018
  private readonly propertyMapper;
971
- constructor(config: Config, stateDb: StateDB, notionClient: NotionClient, vaultFs: VaultFS, pipeline: ConversionPipeline, imageHandler: ImageHandler);
1019
+ private readonly baseFileGenerator;
1020
+ constructor(config: Config, stateDb: IStateDB, notionClient: NotionClient, vaultFs: VaultFS, pipeline: ConversionPipeline, imageHandler: ImageHandler);
972
1021
  pullAll(): Promise<DatabaseSyncResult>;
973
1022
  pushAll(): Promise<DatabaseSyncResult>;
974
1023
  pullDatabase(dbConfig: DatabaseSyncConfig): Promise<DatabaseSyncResult>;
975
1024
  private pullDatabaseViews;
1025
+ private generateBaseFile;
976
1026
  private pullDatabasePage;
977
1027
  private pushDatabase;
978
1028
  }
@@ -1146,7 +1196,7 @@ interface ResolutionResult {
1146
1196
  declare class ConflictResolver {
1147
1197
  private readonly stateDb;
1148
1198
  private readonly vaultFs;
1149
- constructor(stateDb: StateDB, vaultFs: VaultFS);
1199
+ constructor(stateDb: IStateDB, vaultFs: VaultFS);
1150
1200
  resolve(conflict: Conflict, choice: ResolutionChoice): Promise<ResolutionResult>;
1151
1201
  resolveByStrategy(conflict: Conflict, strategy: ConflictStrategy): Promise<ResolutionResult>;
1152
1202
  resolveAll(conflicts: Conflict[], strategy: ConflictStrategy): Promise<ResolutionResult[]>;
@@ -1306,6 +1356,40 @@ declare class EntryEditor {
1306
1356
  updateDate(entryPath: string, dateProperty: string, newDate: string): Promise<void>;
1307
1357
  }
1308
1358
 
1359
+ interface BasePropertySchema {
1360
+ readonly id: string;
1361
+ readonly type: string;
1362
+ readonly options?: Array<{
1363
+ name: string;
1364
+ color?: string;
1365
+ }>;
1366
+ readonly groups?: Array<{
1367
+ name: string;
1368
+ color?: string;
1369
+ optionIds?: string[];
1370
+ }>;
1371
+ }
1372
+ interface BaseFileOptions {
1373
+ readonly databaseId: string;
1374
+ readonly databaseName: string;
1375
+ readonly schema: Record<string, BasePropertySchema>;
1376
+ readonly viewsConfig: DatabaseViewsConfig;
1377
+ readonly folderPath: string;
1378
+ }
1379
+ declare class BaseFileGenerator {
1380
+ generate(options: BaseFileOptions): string;
1381
+ private writeFilters;
1382
+ private needsContentCoverFormula;
1383
+ private writeFormulas;
1384
+ private writePropertyDisplayNames;
1385
+ private writeViews;
1386
+ private convertView;
1387
+ private toNoteRef;
1388
+ private resolvePropertyName;
1389
+ private yamlKey;
1390
+ private yamlValue;
1391
+ }
1392
+
1309
1393
  declare function sortEntries(entries: DBEntry[], sorts: NonNullable<ViewConfig["sorts"]>): DBEntry[];
1310
1394
  declare function groupEntries(entries: DBEntry[], groupByProperty: string, options?: {
1311
1395
  sort?: "ascending" | "descending";
@@ -1318,6 +1402,13 @@ declare function getVisibleProperties(viewConfig: ViewConfig): Array<{
1318
1402
  name: string;
1319
1403
  width?: number;
1320
1404
  }>;
1405
+ interface FilterCondition {
1406
+ property: string;
1407
+ operator: "equals" | "contains" | "startsWith" | "isEmpty" | "isNotEmpty" | "gt" | "lt" | "between";
1408
+ value?: string | number | boolean;
1409
+ valueTo?: string | number;
1410
+ }
1411
+ declare function filterEntries(entries: DBEntry[], searchQuery?: string, filters?: FilterCondition[]): DBEntry[];
1321
1412
 
1322
1413
  declare function getNotionColor(color: NotionColor | string): string;
1323
1414
  declare function getNotionBgColor(color: NotionColor | string): string;
@@ -1346,4 +1437,4 @@ interface PipelineOptions {
1346
1437
  }
1347
1438
  declare function createDefaultPipeline(options?: PipelineOptions): ConversionPipeline;
1348
1439
 
1349
- export { BlockConverter, type CalendarEntry, CalloutRestorer, CalloutTransformer, ChangeDetector, ColorAnnotator, type Config, ConfigManager, ConfigSchema, type Conflict, ConflictResolver, type ConflictStrategy, type ConversionContext, type ConversionPath, ConversionPipeline, type ConversionResult, type CoverConfig, type DBEntry, DEFAULT_CONFIG, type DatabaseSyncConfig, type DatabaseSyncResult, DatabaseSyncer, type DatabaseViewsConfig, EmbedResolver, EntryEditor, type FailedOperation, type FileDownloadResult, FileHandler, type FileInfo, type FileStatInfo, type FileSystemEntry, type FileType, type FileUploadResult, FileWatcher, FrontmatterExtractor, FrontmatterGenerator, type GroupByConfig, type GroupedEntries, HtmlAnnotationStripper, type ImageDownloadResult, ImageHandler, type ImageReference, InlineDBParser, type LocalChange, LocalImageRestorer, type Logger, type MappingResult, type MappingType, MathNormalizer, MentionToWikilink, type MergeConflictRegion, type MergeResult, NodeVaultFS, type NonMdFileInfo, type NotionBlock, NotionBlockBuilder, NotionClient, type NotionClientOptions, type NotionColor, type NotionPageNode, type NotionRichText, type RichTextItem as NotionRichTextItem, type OperationType, type PageCover, type PageCreationPlan, type PageIcon, type PathFilterConfig, type PreserveMarker, PreserveMarkerCollector, PreserveMarkerInjector, type Processor, type ProcessorInput, type ProcessorMetadata, type ProcessorOutput, type ProgressCallback, type ProgressItem, PropertiesTableInjector, PropertiesTableRestorer, PropertyMapper, type PropertyOption, type PropertySchema, type PropertyValue, type PullOptions, type PullResult, type PushOptions, type PushResult, type RemoteChange, type ResolutionChoice, type ResolutionResult, type RichTextSegment, StateDB, type StatusResult, type SyncDirection, type SyncOptions, SyncOrchestrator, type SyncRecord, type SyncResult, type SyncStatus, TreeMapper, UnsupportedBlockStripper, type UpsertSyncRecord, type VaultFS, type ViewConfig, ViewDataProvider, type ViewPropertyConfig, type ViewRenderData, type ViewType, type WatchSyncOptions, WatchSyncService, type WikilinkEntry, WikilinkResolver, computeBufferHash, computeHash, createDefaultPipeline, extractCalendarEntries, filterByMonth, generateColorCSS, generateId, getLogger, getNotionBgColor, getNotionColor, getVisibleProperties, groupEntries, normalizeNotionId, notionIdsEqual, sanitizeFileName, setLogger, sortEntries, threeWayMerge };
1440
+ export { BaseFileGenerator, type BaseFileOptions, type BasePropertySchema, BlockConverter, type CalendarEntry, CalloutRestorer, CalloutTransformer, ChangeDetector, ColorAnnotator, type Config, ConfigManager, ConfigSchema, type Conflict, ConflictResolver, type ConflictStrategy, type ConversionContext, type ConversionPath, ConversionPipeline, type ConversionResult, type CoverConfig, type DBEntry, DEFAULT_CONFIG, type DatabaseSyncConfig, type DatabaseSyncResult, DatabaseSyncer, type DatabaseViewsConfig, EmbedResolver, EntryEditor, type FailedOperation, type FileDownloadResult, FileHandler, type FileInfo, type FileRegistryEntry, type FileStatInfo, type FileSystemEntry, type FileType, type FileUploadResult, FileWatcher, type FilterCondition, FrontmatterExtractor, FrontmatterGenerator, type GroupByConfig, type GroupedEntries, HtmlAnnotationStripper, type IStateDB, type ImageDownloadResult, ImageHandler, type ImageReference, InlineDBParser, type LocalChange, LocalImageRestorer, type Logger, type MappingResult, type MappingType, MathNormalizer, MentionToWikilink, type MergeConflictRegion, type MergeResult, NodeVaultFS, type NonMdFileInfo, type NotionBlock, NotionBlockBuilder, NotionClient, type NotionClientOptions, type NotionColor, type NotionPageNode, type NotionRichText, type RichTextItem as NotionRichTextItem, type OperationType, type PageCover, type PageCreationPlan, type PageIcon, type PathFilterConfig, type PreserveMarker, PreserveMarkerCollector, PreserveMarkerInjector, type Processor, type ProcessorInput, type ProcessorMetadata, type ProcessorOutput, type ProgressCallback, type ProgressItem, PropertiesTableInjector, PropertiesTableRestorer, PropertyMapper, type PropertyOption, type PropertySchema, type PropertyValue, type PullOptions, type PullResult, type PushOptions, type PushResult, type RegisterFileInput, type RemoteChange, type ResolutionChoice, type ResolutionResult, type RichTextSegment, StateDB, type StatusResult, type SyncDirection, type SyncOptions, SyncOrchestrator, type SyncRecord, type SyncResult, type SyncStatus, TreeMapper, UnsupportedBlockStripper, type UpsertSyncRecord, type VaultFS, type ViewConfig, ViewDataProvider, type ViewPropertyConfig, type ViewRenderData, type ViewType, type WatchSyncOptions, WatchSyncService, type WikilinkEntry, WikilinkResolver, computeBufferHash, computeHash, createDefaultPipeline, extractCalendarEntries, filterByMonth, filterEntries, generateColorCSS, generateId, getLogger, getNotionBgColor, getNotionColor, getVisibleProperties, groupEntries, normalizeNotionId, notionIdsEqual, sanitizeFileName, setLogger, sortEntries, threeWayMerge };